package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 充值申请记录表
 * 对应数据库表：yoshop_user_balance_apply
 * 
 * @author 系统生成
 * @since 2025-01-27
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "充值申请记录表")
public class UserBalanceApply extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "balance_apply_id", type = IdType.AUTO)
    @Schema(description = "主键id")
    private Long balanceApplyId;

    /**
     * 用户id
     */
    @TableField("user_id")
    @Schema(description = "用户id")
    private Long userId;

    /**
     * 充值后台id
     */
    @TableField("store_user_id")
    @Schema(description = "充值后台id")
    private Long storeUserId;

    /**
     * 审核业务员id
     */
    @TableField("salesman_store_user_id")
    @Schema(description = "审核业务员id")
    private Long salesmanStoreUserId;

    /**
     * 充值金额
     */
    @Schema(description = "充值金额")
    private BigDecimal money;

    /**
     * 变更前基本账户
     */
    @TableField("before_balance")
    @Schema(description = "变更前基本账户")
    private BigDecimal beforeBalance;

    /**
     * 变更前返利账户
     */
    @TableField("before_rebate")
    @Schema(description = "变更前返利账户")
    private BigDecimal beforeRebate;

    /**
     * 变更前核销账户
     */
    @TableField("before_writeoff")
    @Schema(description = "变更前核销账户")
    private BigDecimal beforeWriteoff;

    /**
     * 申请方式(10需后台审核 20无需审核)
     */
    @TableField("balance_type")
    @Schema(description = "申请方式(10需后台审核 20无需审核)")
    private Integer balanceType;

    /**
     * 申请时间
     */
    @TableField("balance_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "申请时间")
    private Long balanceTime;

    /**
     * 审核状态 (10待审核 20审核通过 30驳回)
     */
    @TableField("balance_status")
    @Schema(description = "审核状态 (10待审核 20审核通过 30驳回)")
    private Integer balanceStatus;

    /**
     * 审核时间
     */
    @TableField("audit_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "审核时间")
    private Long auditTime;

    /**
     * 驳回原因
     */
    @TableField("reject_reason")
    @Schema(description = "驳回原因")
    private String rejectReason;

    /**
     * 凭证
     */
    @Schema(description = "凭证")
    private String images;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private Long createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    private Long updateTime;

    /**
     * 申请方式文本
     */
    @TableField(exist = false)
    @Schema(description = "申请方式文本")
    private String balanceTypeText;

    /**
     * 审核状态文本
     */
    @TableField(exist = false)
    @Schema(description = "审核状态文本")
    private String balanceStatusText;

    /**
     * 关联用户信息
     */
    @TableField(exist = false)
    @Schema(description = "关联用户信息")
    private User user;

    /**
     * 关联业务员信息
     */
    @TableField(exist = false)
    @Schema(description = "关联业务员信息")
    private StoreUser storeUser;

    /**
     * 获取申请方式文本
     * @return 申请方式文本
     */
    public String getBalanceTypeText() {
        if (balanceType == null) {
            return "";
        }
        switch (balanceType) {
            case 10:
                return "需后台审核";
            case 20:
                return "无需审核";
            default:
                return "未知方式";
        }
    }

    /**
     * 获取审核状态文本
     * @return 审核状态文本
     */
    public String getBalanceStatusText() {
        if (balanceStatus == null) {
            return "";
        }
        switch (balanceStatus) {
            case 10:
                return "待审核";
            case 20:
                return "审核通过";
            case 30:
                return "驳回";
            case 40:
                return "复核通过";
            default:
                return "未知状态";
        }
    }
} 